#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef struct {int v,nxt;}edge;

const int MAXN = 2e5+10;

ll f[MAXN][2];
int n,c[MAXN],h[MAXN],cnt;
edge e[MAXN<<1];
bool isleaf[MAXN],chose[MAXN],vvv[MAXN][2];

void link(int x,int y){e[++cnt] = edge{y,h[x]};h[x] = cnt;}

struct plan{
	bool choseit,toleave,allok;
	vector <int> leave;
}g[MAXN][2];

void dfs(int x,int p){
	ll mx = -1;vector<int> leave;
	isleaf[x] = 1;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		if(y == p) continue;
		dfs(y,x);
		isleaf[x] = 0;
		f[x][0] += f[y][0];
		if(f[y][0] - f[y][1] > mx) mx = f[y][0] - f[y][1],leave.resize(0);
		if(f[y][0] - f[y][1] == mx) leave.push_back(y);
	}
	if(isleaf[x]) {
		f[x][1] = 0;
		f[x][0] = c[x];
		return;
	}
	f[x][1] = f[x][0] - mx;
	g[x][1].toleave = 1;g[x][1].leave = leave; g[x][1].choseit = 0;
	if(f[x][1] + c[x] < f[x][0]){
		f[x][0] = f[x][1] + c[x];
		g[x][0].toleave = 1;g[x][0].leave = leave;g[x][0].choseit = 1;
	}else if(f[x][1] + c[x] == f[x][0]){
		g[x][0].allok = 1;
		g[x][0].toleave = 1;g[x][0].leave = leave;g[x][0].choseit = 1;
	}else{
		g[x][0].choseit = 0;
		g[x][0].toleave = 0;
	}
}

void getplan(int x,int y,int p){
	if(vvv[x][y]) return;
	vvv[x][y] = 1;
	if(isleaf[x]){
		if(y == 0) chose[x] = 1;
		return;
	}
	map<int,bool> vis;
	if(g[x][y].choseit) chose[x] = 1;
	for(int i = 0;i < g[x][y].leave.size();i++){
		int v = g[x][y].leave[i];
		getplan(v,1,x);
		if(g[x][y].allok || g[x][y].leave.size() > 1) getplan(v,0,x);
	}
	for(int i = 0;i < g[x][y].leave.size();i++){
		int v = g[x][y].leave[i];
		vis[v] = 1;
	}
	for(int i = h[x];i;i = e[i].nxt){
		int v = e[i].v;
		if(v == p || vis[v]) continue;
		getplan(v,0,x);
	}
}

int main (){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&c[i]);
	for(int i = 1;i < n;i++) {int x,y;scanf("%d %d",&x,&y);link(x,y);link(y,x);}
	dfs(1,0);
	printf("%lld ",f[1][0]);
	getplan(1,0,0);
	int tot = 0;
	for(int i = 1;i <= n;i++) if(chose[i]) tot++;
	printf("%d\n",tot);
	for(int i = 1;i <= n;i++) if(chose[i]) printf("%d ",i);
}
